<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>捉元素</title>
	<script>
		
		window.onload = function () {
			
			title = document.getElementById('title');

			title.style.background='red';

			item = document.getElementsByClassName('item');

			for (var i = 0; i < item.length; i++) {
				item[i].style.background = "red";
			}

			i = document.getElementsByTagName('i');

			i[0].style.background = "red";

			console.log(title);
			console.log(item);
			console.log(i);

			b = document.getElementById('box').getElementsByTagName('b');

			console.log(b);


		}
	</script>
</head>
<body>
	<p class="item">我是p</p>
	<p class="item">我是p</p>
	<p class="item">我是p</p>
	<p class="item">我是p</p>
	<p class="item">我是p</p>
	<p class="item">我是p</p>
	<span id='title'>我是span</span>
	<i>我是i</i>
	<div id="box">
		<b>我是b</b>
	</div>
	<b>我是b</b>
</body>
</html>